*Wellman___APSR___Replication
*July 21, 2020

***********************************
*This File creates Figure 1, Figure 2, and results from Table 3 
***********************************

* Set the working directory to the main folder with the data files

************************************
*Figure 1*
************************************
set scheme burd

clear
graph set window fontface "Times New Roman"
input cid year e_type

1 1992 1 // Angola
1 1992 2
1 2008 2
*1 2010 4 // abolished with 2010 constitution 
2 1990 1 // Benin
2 1991 3 
2 1996 2 
2 2001 2
2 2006 2
2 2011 3 
3 1997 1 // Botswana
3 1999 3
3 2004 3
3 2009 3
3 2014 3
4 2009 1 // Burkina Faso
4 2015 2 
5 1993 1 // Burundi
5 1993 3
5 2010 3
5 2015 3
6 2011 1 // Cameroon
6 2011 3 
7 1990 1 // Cape Verde
7 1991 3 // leg only
7 1995 3 // 
7 1996 3 //
7 2001 3 // both pres, leg
7 2006 3 // both pres, leg
7 2011 3 // both pres, leg
8 2004 1 // CAR
8 2005 3 
8 2011 3
8 2015 3
9 1995 1 // Chad
9 1996 3 
9 2001 2 // .e can't tell (could be 2) 
9 2006 2 // .e can't tell (could be 2) 
9 2011 3 
10 2005 1 // Comoros
10 2006 2 
10 2010 2
11 2001 1 // Congo
11 2002 2
11 2007 2
11 2009 2
11 2012 2 
12 2000 1 // CdI
12 2010 3
12 2015 3
13 1992 1 // Djibouti
13 1993 2 //.e can't tell (could be 2) 
13 1999 3
13 2005 3
13 2011 3
14 1998 1 // Gabon
14 1998 2 // .e can't tell (could be 2) 
14 2005 3
14 2009 3
15 2006 1 // Ghana
15 2008 2
15 2012 2
16 1991 1 // Guinea
16 1993 3 
16 1995 2 // .e can't tell (could be 2) 
16 1998 2 // .e can't tell (could be 2) 
16 2002 2 // .e can't tell (could be 2) 
16 2003 2 // .e can't tell (could be 2) 
16 2010 3 
16 2013 3 
16 2015 3
17 1994 1 // Guinea-Bissau 
17 1994 3
17 1999 2
17 2004 2
17 2008 2
17 2014 3
18 2010 1 // Kenya
18 2013 3 
19 1991 1 // Mali
19 1992 3
19 1997 3
19 2002 3
19 2007 3
19 2013 3
20 2009 1 // Mauritania
20 2009 3
20 2013 3
20 2014 3 
21 1993 1 // Mozambique 
21 1994 2 
21 1999 2
21 2004 3 
21 2009 3
21 2014 3
22 1994 1 // Namibia
22 1999 2 
22 2004 2
22 2009 3
22 2014 3 
23 1992 1 // Niger
23 1993 2
23 1996 2
23 1999 2
23 2004 2
23 2011 2
24 2003 1 // Rwanda 
24 2003 3 
24 2008 3
24 2010 3
24 2013 3
25 1990 1 // Sao Tome
25 1991 3
25 1996 3
25 2001 3
25 2006 3
25 2011 3
26 1992 1 // Senegal 
26 1993 3 
26 1998 3
26 2000 3
26 2001 3
26 2007 3
26 2012 3
27 2012 1 // Sierra Leone
27 2012 2
28 1993 1 // South Africa
28 1994 3 
*28 1998 4 //abolish, place an x 
28 2009 1 
28 2009 3
28 2014 3
29 1992 1 // Togo
29 1993 2
29 1994 2
29 1998 2
29 1999 2
29 2002 2
29 2003 2
29 2005 2
29 2007 2
29 2010 2
29 2013 2
29 2015 2 
end

qui summ cid
replace cid = r(max) - cid + 1

#d ;
label define cid
	29 "Angola"
	28 "Benin"
	27 "Botswana"
	26 "Burkina Faso"
	25 "Burundi"
	24 "Cameroon"
	23 "Cape Verde"
	22 "CAR"
	21 "Chad"
	20 "Comoros"
	19 "Congo"
	18 "Cote d'Ivoire"
	17 "Djibouti"
	16 "Gabon"
	15 "Ghana"
	14 "Guinea"
	13 "Guinea-Bissau"
	12 "Kenya"
	11 "Mali"
	10 "Mauritania"
	9 "Mozambique"
	8 "Namibia"
	7 "Niger"
	6 "Rwanda"
	5 "Sao Tome & Principe"
	4 "Senegal"
	3 "Sierra Leone"
	2 "South Africa"
	1 "Togo", replace;
#d cr
label val cid cid

preserve
	keep cid
	duplicates drop
	gen year = 2015
	tempfile y2015
	save `y2015'
restore
merge m:1 cid year using `y2015', nogen

egen maxyear = max(year), by(cid)

loc lines ""
qui summ cid
forval c=1/`r(max)' {
	loc lines "`lines' line cid year if cid==`c', lc(gs10) ||"
}
tw `lines' scatter cid year if e_type==1, ms(Dh) col(black) ///
	|| scatter cid year if e_type==2, ms(Oh) col(black)  ///
	|| scatter cid year if e_type==3, ms(O) col(black)  ///
	|| scatter cid year if e_type==4, ms(X) col(black)  ///
	ylab(1/29,val angle(0) labsize(2.5)) xtitle("Year") ytitle("") ///
	legend(order(30 "Year of Enfranchisement" 31 "Election (no imp)" 32 "Election (imp)") row(1) pos(6)) ///
	aspectratio(.65, place(east)) 
	
*graph export africafigv75.pdf, width(2000) replace
*graph export Wellman_APSR_Fig1.pdf, width(2000) replace
graph export Wellman_APSR_Fig1.pdf, replace

**************************************
*Table 3*
**************************************
use "Wellman_APSR_reduced_working.dta", clear

xtset ccode year

xtreg Polls Dias_Support Polity2 TaxGDPlag2ln2020 frenchpor DiasPoplagln2020, cluster(stateid)
xtreg Polls Dias_Support Polity2 TaxGDPlag2ln2020 frenchpor DiasPoplagln2020 Rec_Near_Imp EMBcapacity2020, cluster(stateid)
xtreg Polls i.Dias_Support Polity2 TaxGDPlag2ln2020 frenchpor DiasPoplagln2020 Rec_Near_Imp EMBcapacity2020, cluster(stateid)
xtreg ID_access i.Dias_Support Polity2 TaxGDPlag2ln2020 frenchpor DiasPoplagln2020 Rec_Near_Imp EMBcapacity2020, cluster(stateid)

***********************
*Figure 2*
***********************

la var Polls "Polling station access"
la var ID_access "Voter ID access"

xtreg Polls i.Dias_Support Polity2 TaxGDPlag2ln2020 frenchpor DiasPoplagln2020 Rec_Near_Imp EMBcapacity2020, cluster(stateid)
estimates store Polls
xtreg ID_access i.Dias_Support Polity2 TaxGDPlag2ln2020 frenchpor DiasPoplagln2020 Rec_Near_Imp EMBcapacity2020, cluster(stateid)
estimates store ID

coefplot (Polls, ms(c) mcolor(black) drop(_cons) ciopts(color(black)) label("Polling Station Access")) ///
	(ID, msymbol(S) mcolor(gs10) drop(_cons) ciopts(color(gs10)) xline(0, lc(black)) ///
	label("Voter ID Access")), legend(pos(6))
	
graph export Wellman_APSR_Fig2.pdf, replace 
	





